class CreateKuztuscmsLayouts < ActiveRecord::Migration
  def change
    create_table :kuztuscms_layouts do |t|
      t.text :body
      t.string :path
      t.string :format
      t.string :locale
      t.string :handler
      t.boolean :partial, :default => false

      t.timestamps
    end

    body = <<EOF
<!DOCTYPE html>
<html>
<head>
  <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  <meta name="keywords" content="<%= Kuztuscms.page.keywords %>" />
  <meta name="description" content="<%= Kuztuscms.page.description %>" />
  <title><%= Kuztuscms.page.title %></title>
  <%= stylesheet_link_tag    "application", :media => "all" %>
  <%= javascript_include_tag "application" %>
  <%= csrf_meta_tags %>
</head>
<body>
  <%= render Kuztuscms.template_path('google-analytics') %>
  <p class=notice><%= notice %></p>
  <p class=alert><%= alert %></p>
  <%= yield %>
</body>
</html>
EOF
    Kuztuscms::Layout.create(
      :body => body, 
      :path => 'default', 
      :format => 'html', 
      :locale => 'en', 
      :handler => 'erb', 
      :partial => false
    )
  end
end
